package day1127_2;

import java.sql.*;

public class D2 {
    public static void main(String[] args)throws  Exception{
        //1.加载数据库驱动类
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection  conn= DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/big2?serverTimezone=GMT%2B8&useSSL=false",
                "root","root");//2.
        PreparedStatement  stmt=
                conn.prepareStatement("select * from stu  where id=?");//3.传输对象
        stmt.setInt(1, 1);//给第一个问好号处 存入一个1
        ResultSet rs=stmt.executeQuery();     //stmt.execute()//4.执行SQL
        rs.next();
        System.out.println(rs.getInt(1));//5.获取查询结果
        System.out.println(rs.getString(2));//5.获取查询结果
        //executeUpdate(): 删除数据/数据库  修改数据/数据库   插入数据
        conn.close();//6.关闭链接
    }
}






